package main

import "fmt"

type Op func(int) (int, Op)

func Add(a int) Op {
	return func(i2 int) (int, Op) {
		return a + i2, Add(a + i2)
	}
}

func Multi(a int) Op {
	return func(i2 int) (int, Op) {
		return a * i2, Multi(a * i2)
	}
}

func main() {

	add := Multi(1)

	for i := 1; i < 10; i++ {
		var s int
		s, add = add(i)
		fmt.Printf("0 + 1 + ... + %d = %d\n", i, s)
	}
}
